/**
 * @(#) EpuckProximitySensor.java
 */

package pcsr.drivers.epuckDriver;

import pcsr.drivers.epuckDriver.command.IePuckUartProtocol.ProximityNumber;

class EpuckProximitySensor implements IEpuckSensor
{
	private ProximityNumber sensorNumber;
	private short sensorvalue;
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String GetID() {
		return sensorNumber.name();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public EpuckSensorMode GetMode() {
		return EpuckSensorMode.GETVALUEONLY;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public EpuckSensorType GetType() {
		return EpuckSensorType.PERIMETER;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public short GetValue() {
		return sensorvalue;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void SetValue(short newValue) {
		SetSensorValue(newValue);
	}

	/**
	 * @return the sensorNumber
	 */
	ProximityNumber GetSensorNumber() {
		return sensorNumber;
	}

	/**
	 * @return the sensorvalue
	 */
	short GetSensorValue() {
		return sensorvalue;
	}

	/**
	 * @param sensorNr the sensor number to set
	 */
	void SetSensorNumber(int sensorNr) {
		switch (sensorNr) {
		case 1:
			sensorNumber = ProximityNumber.PROXIMITY_1;
			break;
		case 2:
			sensorNumber = ProximityNumber.PROXIMITY_2;
			break;
		case 3:
			sensorNumber = ProximityNumber.PROXIMITY_3;
			break;
		case 4:
			sensorNumber = ProximityNumber.PROXIMITY_4;
			break;
		case 5:
			sensorNumber = ProximityNumber.PROXIMITY_5;
			break;
		case 6:
			sensorNumber = ProximityNumber.PROXIMITY_6;
			break;
		case 7:
			sensorNumber = ProximityNumber.PROXIMITY_7;
			break;
		case 8:
			sensorNumber = ProximityNumber.PROXIMITY_8;
			break;
		default:
			break;
		}
	}

	/**
	 * @param sensorvalue the sensorvalue to set
	 */
	void SetSensorValue(short sensorvalue) {
		this.sensorvalue = sensorvalue;
	}

	public EpuckProximitySensor(ProximityNumber pn)
	{
		sensorNumber = pn;
	}
	
}
